package com.keggview.application.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.part.ViewPart;

public class PropertiesView extends ViewPart {
	
	public static final String ID = "com.keggview.application.views.propertiesview";

	public PropertiesView() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void createPartControl(Composite parent) {
//		TreeViewer tree = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
//		tree.setContentProvider(new TreeElementsContentProvider());
		
		
//		tree.setLabelProvider(new TreeElementsLabelProvider());
		final Tree main = new Tree(parent, SWT.VIRTUAL | SWT.BORDER | SWT.CHECK	);
		main.setItemCount(20);
		main.addListener(SWT.SetData, new Listener() {
			public void handleEvent(Event event) {
				TreeItem item = (TreeItem)event.item;
				TreeItem parentItem = item.getParentItem();
				String text = null;
				if (parentItem == null) {
					text = "node " + main.indexOf(item);
				} else {
					text = parentItem.getText() + " - " + parentItem.indexOf(item);
				}
				item.setText(text);
				System.out.println(text);
				item.setItemCount(10);
			}
		});
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}
	
}
